package wx.controls
{
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;
	
	import wx.core.Control;
	import wx.core.ITheme;
	import wx.core.SettingCache;
	
	/**
	 * 
	 * @author
	 * 文本标签控件
	 * 
	 */	
	public class Label extends Control
	{
		
		/**
		 *文本 
		 */		
		private var _text:String;
		
		/**
		 *颜色 
		 */		
		private var _color:Object;
		
		/**
		 *大小 
		 */		
		private var _size:Object;
		
		
		private var _tfd:TextField;
		private var _tfmt:TextFormat;
		
		private const _theme:ITheme = SettingCache.theme;
		
		public function Label($text:String="", $color:Object=null, $size:Object=null)
		{
			super();
			
			_text = $text;
			_color = $color!=null?$color:_theme.mediumFontColor; //取皮肤默认值
			_size = $size!=null?$size:_theme.mediumFontSize;
			
			_tfmt = new TextFormat(null, _size, _color);
			
			_tfd = new TextField();
			_tfd.mouseEnabled = false;
			_tfd.selectable = false;
			_tfd.defaultTextFormat = _tfmt;
			_tfd.autoSize = TextFieldAutoSize.LEFT;
			_tfd.text = _text;
			addChild(_tfd);
		}		
		
		public function get size():Object
		{
			return _size;
		}

		public function set size(value:Object):void
		{
			if(_size != value){
				_size = value;
				_tfmt.size = value;
				_tfd.setTextFormat(_tfmt);
			}
		}

		public function get color():Object
		{
			return _color;
		}

		public function set color(value:Object):void
		{
			if(_color != value){
				_color = value;
				_tfmt.color = value;
				_tfd.setTextFormat(_tfmt);
			}
		}

		public function get text():String
		{
			return _text;
		}

		public function set text(value:String):void
		{
			if(_text != value){
				_text = value;
				_tfd.text = value;
			}
		}
	}
}